FROM gcr.io/cloud-marketplace/google/ubuntu2204

COPY requirements.txt .
COPY requirements_py2.txt .

RUN apt-get -y update && \
    apt-get dist-upgrade -y && \
    apt-get -y install gcc python2.7 python3-pip wget ca-certificates curl openssl bzip2 \
       # These are necessary for add-apt-respository
       software-properties-common && \

    # Install Git >2.0.1
    add-apt-repository ppa:git-core/ppa && \
    apt-get -y update && \
    apt-get -y install git && \

    # Setup Google Cloud SDK (latest)
    mkdir -p /builder && \
    wget -qO- https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz | tar zxv -C /builder && \
    /builder/google-cloud-sdk/install.sh --usage-reporting=false \
        --bash-completion=false \
        --disable-installation-options && \

    # install crcmod: https://cloud.google.com/storage/docs/gsutil/addlhelp/CRC32CandInstallingcrcmod
    pip install --require-hashes -r requirements_py2.txt && \
    pip3 install --require-hashes -r requirements.txt && \

    # Clean up
    apt-get -y remove gcc wget python-pip python3-pip && \
    rm -rf /var/lib/apt/lists/* && \
    rm -rf ~/.config/gcloud

COPY notice.sh /builder

ENV PATH=/builder/google-cloud-sdk/bin/:$PATH
RUN git config --system credential.helper gcloud.sh

ENTRYPOINT ["/builder/notice.sh"]
